﻿using System;
using System.Collections.Generic;
using System.Web;
using Rabbit.Logic;
using RabbitManage.Code;

namespace RabbitManage.UI
{
    public partial class ShipRuleCity : System.Web.UI.Page
    {
        protected List<ProvinceCity> list;
        protected string provinceAfar = CityData.Afar;
        protected string Data = CityData.CityJson;
        protected Dictionary<string, decimal> dic;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            list = CityData.GetMainlandData();

            HttpCookie cookie = Request.Cookies[Constant.CookieName];
            string shopId = cookie.Values[Constant.CookieUid];
            ShipRule rule = RabbitUse.GetShipRuleByShopId(Db.Store, shopId);
            if (rule == null)
            {
                dic = new Dictionary<string, decimal>();
                foreach (var provinceCity in list)
                {
                    dic[provinceCity.Name] = 0m;
                }
            }
            else
            {
                dic = rule.Rules;
            }
            costRepeater.DataSource = dic;
            costRepeater.DataBind();
        }
    }
}